﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcDemo1WebUI.Models;

namespace MvcDemo1WebUI.Controllers
{
    public class BankController : Controller
    {
        //
        // GET: /Bank/
        public ActionResult Edit(AccountInfo acctInfo)
        {
            return View(acctInfo);
        }
        public ActionResult Index()
        {
            var acctModel = GetAccounts();
            return View(acctModel);
        }
        public ActionResult Loan()
        {
            return View();
        }
        public ActionResult Accouts()
        {
            BankAccountsModel bamModel = GetAccounts();

            return View(bamModel);
        }
        public ActionResult Accounts()
        {
            BankAccountsModel bamModel = GetAccounts();

            return View(bamModel);
        }


        private BankAccountsModel GetAccounts()
        {
            BankAccountsModel bamModel = new BankAccountsModel();
            bamModel.Branch = "Garia";
            //AccountInfo act = new AccountInfo();
            //act.AcctNo= "101";
            //act.AcctName = "Arun";
            //act.AcctContactNo = "9830132137";
            //bamModel.Accts.Add(act); //new AccountInfo {AcctNo = "101", AcctName = "Arun", AcctContactNo = "9830132137"});

            //var x = new {Roll = 101, Name = "Arun", Age = 21};
            //if (x.Age > 100)
            //    x.Age = 20;

            List<AccountInfo> acctList = new List<AccountInfo>();
            acctList.Add(new AccountInfo { AcctNo = "101", AcctName = "Arun", AcctContactNo = "9830132137" });
            acctList.Add(new AccountInfo { AcctNo = "102", AcctName = "Barun", AcctContactNo = "9836542137" });
            acctList.Add(new AccountInfo { AcctNo = "103", AcctName = "Kiran", AcctContactNo = "8730132137" });

            bamModel.Accts = acctList;

            return bamModel;
        }
        public List<AccountInfo> GetOnlyAccounts()
        {
            List<AccountInfo> acctList = new List<AccountInfo>();
            acctList.Add(new AccountInfo { AcctNo = "101", AcctName = "Arun", AcctContactNo = "9830132137" });
            acctList.Add(new AccountInfo { AcctNo = "102", AcctName = "Barun", AcctContactNo = "9836542137" });
            acctList.Add(new AccountInfo { AcctNo = "103", AcctName = "Kiran", AcctContactNo = "8730132137" });
            return acctList;
        }
    }
}
